package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;

/**
 * <p><b>PcProductRule Description:</b> PcProductRule po类 ; 二级产品规则 </p>
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-16 15:56:15</p>
 */
@Data
@Entity
@Table(name = "pc_product_rule_new")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PcProductRule implements IRulePo {
	
	/**
	 * <b>Fields</b> serialVersionUID :
	 */
	private static final long serialVersionUID = -6776894190970595800L;

	/**
	 * <b>Fields</b> id : id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PC_PRODUCT_RULE_NEW_SEQ")
	@SequenceGenerator(name = "PC_PRODUCT_RULE_NEW_SEQ", sequenceName = "PC_PRODUCT_RULE_NEW_SEQ", allocationSize = 1)
	private Long id;
	
	/**
	 * <b>Fields</b> productInfoPackageId : 二级产品ID
	 */
	@Column(name = "product_info_package_id")
	private Long productInfoPackageId;
	
	/**
	 * <b>Fields</b> ruleType : 规则类型 1.已选 2.限制
	 */
	@Column(name = "rule_type")
	private String ruleType;
	
	/**
	 * <b>Fields</b> copyrightCpid : 版权所属CP
	 */
	@Column(name = "copyright_cpid")
	private String copyrightCpid;
	
	/**
	 * <b>Fields</b> copyrightScope : 版权授权范围 1.品牌2.全业务3.咪咕
	 */
	@Column(name = "COPYRIGHT_SCOPE")
	private String copyrightScope;
	
	/**
	 * <b>Fields</b> terminal : 版权终端 1.全平台2.手机终端3.PC4.IPTV5.平板6.数字有线网7.互联网电视
	 */
	@Column(name = "TERMINAL")
	private String terminal;
	
	/**版权黑名单 1-内地；2-香港；3-澳门；4-台湾；5-海外；6-不限 版权白名单 1-内地；2-香港；3-澳门；4-台湾；5-海外；6-不限；11-江苏；20-广东
	 * <b>Fields</b> area : 版权地域范围
	 */
	@Column(name = "AREA")
	private String area;
	
	/**
	 * <b>Fields</b> authorizationWay : 授权方式 1.单片授权2.集体授权3.频道授权4.三方SDK播放授权
	 */
	@Column(name = "authorization_way")
	private String authorizationWay;
	
	/**
	 * <b>Fields</b> copyrightType : 版权类型 1.全部2.强版权 3.弱版权
	 */
	@Column(name = "copyright_type")
	private String copyrightType;
	
	/**
	 * <b>Fields</b> digitalCopyrightProtection : 数字版权保护 1.全部 2.是 3.否
	 */
	@Column(name = "digital_copyright_protection")
	private String digitalCopyrightProtection;
	
	/**
	 * <b>Fields</b> deleted : 是否删除 1.是 0. 否
	 */
	@Column(name = "DELETED")
	private Integer deleted = 0;
	
	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;
	
	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private java.time.LocalDateTime createdTime;
	
	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;
	
	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private java.time.LocalDateTime updatedTime;
	
	public static void putTimeAndUser(PcProductRule pcProductRule) {
		if (pcProductRule.id == null) {
			pcProductRule.setCreatedBy(CurrentUser.currUserName());
			pcProductRule.setCreatedTime(java.time.LocalDateTime.now());
		}
		pcProductRule.setUpdatedBy(CurrentUser.currUserName());
		pcProductRule.setUpdatedTime(java.time.LocalDateTime.now());	}
}